<template>
    <div>
        <!-- <div v-if="isLoading" id="loading" style="width:100%;height:100vh;    align-items: center;display: flex;justify-content: center;">
            <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px" height="30px" viewBox="0 0 24 30" style="enable-background:new 0 0 50 50;" xml:space="preserve">
                <rect x="0" y="10" width="4" height="10" fill="#333" opacity="0.2">
                    <animate attributeName="opacity" attributeType="XML" values="0.2; 1; .2" begin="0s" dur="0.6s" repeatCount="indefinite" />
                    <animate attributeName="height" attributeType="XML" values="10; 20; 10" begin="0s" dur="0.6s" repeatCount="indefinite" />
                    <animate attributeName="y" attributeType="XML" values="10; 5; 10" begin="0s" dur="0.6s" repeatCount="indefinite" />
                </rect>
                <rect x="8" y="10" width="4" height="10" fill="#333" opacity="0.2">
                    <animate attributeName="opacity" attributeType="XML" values="0.2; 1; .2" begin="0.15s" dur="0.6s" repeatCount="indefinite" />
                    <animate attributeName="height" attributeType="XML" values="10; 20; 10" begin="0.15s" dur="0.6s" repeatCount="indefinite" />
                    <animate attributeName="y" attributeType="XML" values="10; 5; 10" begin="0.15s" dur="0.6s" repeatCount="indefinite" />
                </rect>
                <rect x="16" y="10" width="4" height="10" fill="#333" opacity="0.2">
                    <animate attributeName="opacity" attributeType="XML" values="0.2; 1; .2" begin="0.3s" dur="0.6s" repeatCount="indefinite" />
                    <animate attributeName="height" attributeType="XML" values="10; 20; 10" begin="0.3s" dur="0.6s" repeatCount="indefinite" />
                    <animate attributeName="y" attributeType="XML" values="10; 5; 10" begin="0.3s" dur="0.6s" repeatCount="indefinite" />
                </rect>
            </svg>
        </div> -->
        <div class="container_person">
            <mt-header fixed title="我的">
                <span slot="right" class="setting" @click="goSetting">设置</span>
            </mt-header>
            <div class="myinfo_top">
                <div class="myinfo_back">
                    <div class="info">
                        <div class="info_icon">
                            <img src="../../assets/image/userinmgs.png">
                        </div>
                        <div class="info_name">
                            <div class="titlename">
                                <span>{{userinfodata.name}}</span>
                            </div>
                            <div class="userinfo">
                                <span>{{userinfodata.company_name}}</span>
                            </div>
                        </div>
                    </div>

                    <hr class="hrclass" />
                    <div class="many_div" @click="hidenmany">
                        <div class="tips">
                            <span style="font-size: 0.4rem">可用额度</span>
                            <span class="fa fa-eye" v-if="hidentype" style="font-size: 0.4rem"></span>
                            <span class="fa fa-eye-slash" v-else style="font-size: 0.4rem"></span>

                        </div>
                        <div class="num">
                            <span class="many_num" v-if="hidentype">{{userinfodata.quota||0}}</span>
                            <span class="many_num" v-else>******</span>
                        </div>
                        <div class="audit">
                            <span>待激活额度 {{userinfodata.credit2Audit}}</span>
                        </div>
                    </div>
                </div>
                <mt-tabbar v-model="selectedtaber" class="panel-bar" @click.native="lookOrder">
                    <mt-tab-item id="1">
                        <img slot="icon" src="../../assets/image/payment.png">
                        待付款
                    </mt-tab-item>
                    <mt-tab-item id="2">
                        <img slot="icon" src="../../assets/image/process.png">
                        处理中
                    </mt-tab-item>
                    <mt-tab-item id="3">
                        <img slot="icon" src="../../assets/image/Completed.png">
                        已完成
                    </mt-tab-item>
                    <mt-tab-item id="0">
                        <img slot="icon" src="../../assets/image/Seeorder.png">
                        查订单
                    </mt-tab-item>
                </mt-tabbar>
            </div>
            <!--消息-->
            <!--<div class="recorddiv">-->
            <!--<span class="record_news"></span>-->
            <!--<span>消息</span>-->
            <!--<span class="fa fa-angle-right"></span>-->
            <!--</div>-->
            <!--<div class="recorddiv_botom" @click="routerclick('Cardvoucher')">-->
            <!--<span class="record_cards"></span>-->
            <!--<span>我的卡券</span>-->
            <!--<span class="fa fa-angle-right"></span>-->
            <!--</div>-->
            <!--<div class="recorddiv_botom" @click="routerclick('PutForward')">-->
            <!--<span class="record_cash"></span>-->
            <!--<span>现金账户</span>-->
            <!--<span class="fa fa-angle-right"></span>-->
            <!--</div>-->
            <div class="recorddiv_botom clear" style="border: 0" @click="routerclick('index-bill')">
                <span class="record_back record_bill"></span>
                <span>账单</span>
                <span class="fa fa-angle-right"></span>
            </div>
            <div class="recorddiv_botom clear" @click="routerclick('Bankcard')">
                <span class="record_back"></span>
                <span>银行卡</span>
                <span class="fa fa-angle-right"></span>
            </div>
            <div class="recorddiv_botom clear" @click="routerclick('learningPlatform')">
                <span class="record_back record_learn"></span>
                <span>学习平台</span>
                <span class="fa fa-angle-right"></span>
            </div>
            <div class="recorddiv_botom clear" @click="routerclick('service')">
                <span class="record_back record_service"></span>
                <span>联系客服</span>
                <span class="tel-part">400 101 5559</span>
                <span class="fa fa-angle-right"></span>
            </div>
            <div class="recorddiv_botom clear" @click="routerclick('leaveOffice')">
                <span class="record_back record_leave"></span>
                <span>离职</span>
                <span class="fa fa-angle-right"></span>
            </div>
            <section class="learve-alert" v-if="leavePart">
                <div class="lear-bg" @click="closeLeave"></div>
                <div class="leave-con">
                    <img src="../../assets/image/bg_frame.png" class="leave-please" @click="closeLeave" v-show="leaveOne" />
                    <img src="../../assets/image/leaved.png" class="leaved" @click="closeLeave" v-show="leaveTwo" />
                    <div class="no-leave" v-show="leaveOne">
                        <h3>别冲动,有事好商量！</h3>
                        <h3>先找我聊聊吧～</h3>
                        <br />
                        <p v-for="item in contact" :key="item.no">{{item.txt}} {{item.no}} </p>
                        <br />
                        <section class="buts">
                            <button v-for="item in contact" :key="item.no" @click="learvePhoe(item.no)">{{item.title}}</button>
                        </section>

                    </div>
                    <div class="already-leaved" v-show="leaveTwo">
                        <p>您已经离职啦～</p>
                    </div>
                    <img src="../../assets/image/but_close.png" @click="closeLeave" class="but-close" />
                </div>
            </section>
        </div>
    </div>
</template>

<script>
import app from '~/assets/api/config'
import os from '~/assets/api/os'
import 'font-awesome/css/font-awesome.min.css'

export default {
    data() {
        return {
            hidentype: '', // 金额显示
            selectedtaber: null, // nar切换
            userinfodata: [], // 个人信息
            leavePart: false,
            leaveOne: false,
            leaveTwo: false,
            contact: [] // 联系电话
        }
    },
    beforeRouteLeave(to, from, next) {
        console.log(this)
        this.$MessageBox.close(false)
        next()
    },
    mounted() {
        this.getuserinfo()
        // this.hidentype=localStorage.getItem('hidentype')||'';
    },
    methods: {
        goSetting() {
            this.$router.push({ name: 'setting' })
        },
        closeLeave() {
            this.leavePart = false
        },
        learvePhoe(telnum) {
            if (os.isIOS()) {
                window.location.href = `tel://${telnum}`
            } else if (os.isAndroidLxkApp()) {
                window.control.call_phone(telnum)
            } else {
                window.location.href = `tel://${telnum}`
            }
        },
        lookOrder() {
            let urlOrder = `${app.API_JD_URL}/orderList?selectId=${this.selectedtaber}&platform=lxk`
            let urlParams = `&token=${localStorage.getItem('token')}`
            if (localStorage.getItem('selected') &&JSON.parse(localStorage.getItem('selected')) >= 0) {
                window.location.href = `${urlOrder}${urlParams}`
            } else {
                window.location.href = `${urlOrder}${urlParams}`
            }
            localStorage.setItem('selected', this.selectedtaber)
        },
        hidenmany() {
            // 隐藏金额
            this.hidentype = this.hidentype ? '' : '1'
            localStorage.setItem('hidentype', this.hidentype)
        },
        routerclick(url) {
            // console.log(url)
            // 跳转
            if (url == 'PutForward') {
                this.$axios
                    .post(
                        app.API_BES_URL +
                            '/api/backend/v1/bill/getHomeBillData',
                        {
                            type: 2
                        }
                    )
                    .then(res => {
                        if (res.data.code == 0) {
                            if (res.data.data == 2) {
                                this.$router.push({ name: 'Bankcard' })
                            } else {
                                this.$router.push({
                                    name: url,
                                    query: { tab: 'cash' }
                                })
                            }
                        }
                    })
            } else if (url == 'service') {
                this.telphonbox()
            } else if (url == 'leaveOffice') {
                // this.leavePart = true;
                this.$axios
                    .get(app.API_BES_URL + '/api/backend/v1/member/quit/check')
                    .then(res => {
                        if (res.data.code == 0) {
                            // status:1->已离职,
                            // 2->无离职记录，可申请,
                            // 3->有审批拒绝的申请，可再次申请,
                            // 4->不可申请：没有开放申请入口 ,
                            // 5->不可申请：已有待审核的申请记录
                            this.leavePart = true
                            if (res.data.data.status == 1) {
                                this.leaveOne = false
                                this.leaveTwo = true
                            } else if (res.data.data.status == 4) {
                                this.leaveOne = true
                                this.leaveTwo = false
                                this.contact = res.data.data.data.contactAt
                            } else if (res.data.data.status == 2) {
                                this.$router.push({ name: url })
                            } else if (res.data.data.status == 3) {
                                this.$router.push({
                                    name: 'approvalStatus',
                                    query: { type: 'refuse' }
                                })
                            } else if (res.data.data.status == 5) {
                                this.$router.push({
                                    name: 'approvalStatus',
                                    query: { type: 'approvaling' }
                                })
                            }
                        }
                    })
            } else {
                this.$router.push({ name: url })
            }
        },

        getuserinfo() {
            //获取个人信息
            this.$axios
                .get(app.API_BES_URL + '/api/backend/v1/member/getInfo')
                .then(res => {
                    if (res.data.code == 0) {
                        this.userinfodata = res.data.data
                    }
                })
        },
        telphonbox() {
            //电话弹框
            if (os.isAndroidLxkApp()) {
                window.control.call_phone('400-101-5559')
            } else {
                window.location.href = 'tel://400-101-5559'
            }
        }
    }
}
</script>

<style lang="less">
.container_person {
    width: 100%;
    margin: 0 auto;
    .setting {
        font-size: 28px;
    }
    .myinfo_top {
        padding: 22.5px;
        background: #fff;
        margin-bottom: 25px;
        .myinfo_back {
            background: url('../../assets/image/me_bg@3x.png') no-repeat;
            background-size: cover;
            height: 389px;
            border-radius: 7.5px;
            margin-bottom: 15px;
            padding: 0 42px;
            margin-top: 90px;
            .info {
                padding-top: 42px;
                .info_icon {
                    width: 80px;
                    height: 80px;
                    border-radius: 150px;
                    overflow: hidden;
                    float: left;
                    img {
                        width: 100%;
                    }
                }
                .info_name {
                    float: left;
                    margin-left: 30px;

                    .titlename {
                        span {
                            color: #fff;
                            font-size: 28px;
                        }
                    }
                    .userinfo {
                        span {
                            color: #fff;
                            font-size: 28px;
                        }
                    }
                }
            }

            .hrclass {
                height: 1.25px;
                border: none;
                border-top: 1.25px solid #ccc;
                width: 100%;
                margin-top: 20px;
                float: left;
            }
            .many_div {
                float: left;
                width: 100%;
                text-align: center;
                color: #fff;
                .tips {
                    span {
                        color: #fff;
                    }
                }

                .many_num {
                    font-size: 60px;
                    line-height: 80px;
                }
            }

            .audit {
                span {
                    font-size: 24px;
                }
            }
        }
        .panel-bar {
            position: static !important;
            bottom: auto !important;
            background: white;
            margin-top: 0;
            border: none;
        }
        .panel-bar > .mint-tab-item .mint-tab-item-icon {
            width: 56.25px !important;
            height: 56.25px !important;
        }
        .panel-bar > .mint-tab-item .mint-tab-item-label {
            font-size: 26.25px !important;
            color: #666;
            margin-top: 22.5px;
        }
        .panel-bar > .mint-tab-item.is-selected {
            background: none;
            color: #333;
        }
    }
    .recorddiv {
        float: left;
        width: 100%;
        margin: 22.5px 0;
        background: #fff;
        padding: 22.5px 0;
        color: #666;
        .record_news {
            background: url('../../assets/image/newsicon.png') no-repeat;
            background-size: 100%;
            width: 43.75px;
            height: 43.75px;
            float: left;
            margin-left: 22.5px;
            margin-right: 30px;
        }
        .fa-angle-right {
            float: right;
            margin-right: 22.5px;
            font-size: 45px;
            color: #999;
        }
    }
    .recorddiv_botom {
        width: 100%;
        background: #fff;
        padding: 13px 0;
        border-top: 1.25px solid #eee;
        position: relative;
        color: #666;
        span {
            font-size: 30px;
        }
        .tel-part {
            position: absolute;
            display: block;
            right: 72.5px;
            top: 50%;
            transform: translateY(-50%);
            font-size: 28px;
            color: #a7a7a7;
        }
        .record_cards {
            background-image: url('../../assets/image/caredindex.png');
        }
        .record_cash {
            background-image: url('../../assets/image/cashicon.png');
        }

        .record_back {
            background: url('../../assets/image/Bankcardicon.png') no-repeat;
            background-size: 100%;
            width: 32.5px;
            height: 32.5px;
            float: left;
            margin-top: 22px;
            margin-left: 38px;
            margin-right: 33px;
        }
        .record_bill {
            background-image: url('../../assets/image/mybillone.png');
            margin-top: 22px;
        }
        .record_learn {
            background-image: url('../../assets/image/icon_book_me.png');
            margin-top: 22px;
        }
        .record_service {
            background-image: url('../../assets/image/icon_phone_me.png');
            margin-top: 22px;
        }
        .record_leave {
            background-image: url('../../assets/image/leave-icon.png');
            margin-top: 22px;
        }
        .fa-angle-right {
            float: right;
            margin-right: 22.5px;
            font-size: 45px;
            color: #999;
            margin-top: 10px;
        }
    }
    .learve-alert {
        position: fixed;
        z-index: 2001;
        .lear-bg {
            position: fixed;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            opacity: 0.5;
            background: #000;
        }

        .leave-con {
            width: 597.5px;
            min-height: 250px;
            background: #fff;
            position: fixed;
            left: 50%;
            top: 50%;
            border-radius: 0 0 15px 15px;
            transform: translate(-50%, -50%);
            .leave-please {
                display: block;
                width: 597.5px;
                height: 227.5px;
                margin-top: -225px;
            }

            .leaved {
                display: block;
                width: 597.5px;
                height: 347.5px;
                margin-top: -345px;
            }

            .no-leave {
                padding-bottom: 50px;
                h3 {
                    display: block;
                    text-align: center;
                    font-weight: 550;
                    color: #1f1f1f;
                    font-size: 32px;
                    line-height: 50px;
                }

                p {
                    display: block;
                    text-align: center;
                    color: #a3a5a9;
                    font-size: 21px;
                    padding: 0px 0 14px;
                }
                .buts {
                    display: flex;
                    justify-content: space-around;
                    button {
                        display: block;
                        width: 40%;
                        height: 56px;
                        border: 0;
                        border-radius: 50px;
                        color: #1d0f00;
                        font-size: 24px;
                        filter: progid:DXImageTransform.Microsoft.Gradient(startColorStr='#ffdf00', endColorStr='#ffcd00', gradientType='1');
                        background: -moz-linear-gradient(
                            left,
                            #ffdf00,
                            #ffcd00
                        );
                        background: -o-linear-gradient(left, #ffdf00, #ffcd00);
                        background: -webkit-gradient(
                            linear,
                            0% 0%,
                            100% 0%,
                            from(#ffdf00),
                            to(#ffcd00)
                        );
                    }
                }
            }
            .already-leaved {
                p {
                    display: block;
                    text-align: center;
                    font-weight: 550;
                    color: #1f1f1f;
                    font-size: 32px;
                    line-height: 200px;
                }
            }
            .but-close {
                display: block;
                width: 75px;
                height: 132.5px;
                position: absolute;
                bottom: -125px;
                left: 50%;
                transform: translateX(-50%);
            }
        }
    }
}
</style>
<style>
.mint-header {
    font-size: 0.45rem !important;
    height: 1.173333rem !important;
    background: #fff !important;
    color: #2e2e2e !important;
    border-bottom: 0.016667rem solid #f8f8f8 !important;
}
.mint-header-title {
    font-size: 0.426667rem !important;
}
.mint-header-button.is-right {
    margin-right: 0.3rem;
}

.mint-msgbox-wrapper .mint-msgbox .mint-msgbox-content {
    padding: 22.5px 15px 30px;
    font-size: 15px;
}

.cancelleft {
    border-right: 1.25px solid #ddd !important;
    border-radius: 30px 0 0 30px;
    overflow: hidden;
}

.cancelright {
    border-radius: 0 30px 30px 0;
    overflow: hidden;
}

.teles {
    font-size: 25px;
}

.teles b {
    font-size: 25px;
}

.mtalert {
    border-radius: 0 0 30px 30px !important;
}
</style>
